//导入request.js请求工具
import request from '@/utils/request.js'


//提供调用登录接口的函数
export const userLoginService = (loginData)=>{
    const params = new URLSearchParams();
    for(let key in loginData){
        params.append(key,loginData[key])
    }
    return request.post('/login',params)
}


//获取用户详细信息
export const teacherInfoService = ()=>{
    return request.get('/teacher/getTeacherInfo')
}

export const studentInfoService = ()=>{
    return request.get('/student/getStudentInfo')
}

//修改个人信息
export const userInfoUpdateService = (userInfoData)=>{
   return request.put('/user/update',userInfoData)
}

export const updateTeacherPasswordService = (passwordForm)=>{
    const params = new URLSearchParams();
    for(let key in passwordForm){
        params.append(key,passwordForm[key])
    }
    return request.post('/teacher/updatePassword',params)
}

export const logoutService = (token) => {
    return request.patch('/logout', null, {
      headers: {
        Authorization: token, // 将 token 放在请求头中
      },
    });
  };

// 获取验证码的函数
export const getCaptchaService = () => {
    return request.get('/identifyImage', {
        responseType: 'blob',
    })
};

